﻿using System;
using System.Diagnostics.CodeAnalysis;
using vBridge.Dwm.Aero.Margins;

namespace vBridge.Dwm.Aero.Glassers
{
    /// <summary>
    ///     Aero-glasses windows.
    /// </summary>
    public class WindowAeroGlasser : IWindowAeroGlasser
    {
        private readonly IntPtr _windowHandle;

        /// <summary>
        ///     Initializes a new instance of the <see cref="WindowAeroGlasser" /> class.
        /// </summary>
        /// <param name="windowHandle">The handle of the window to be aero-glassed.</param>
        public WindowAeroGlasser(IntPtr windowHandle)
        {
            _windowHandle = windowHandle;
        }

        [SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults", MessageId = "vBridge.Dwm.NativeMethods.DwmExtendFrameIntoClientArea(System.IntPtr,vBridge.Dwm.Aero.Margins.Margin@)", Justification = "The interface doesn't allow any utilization of the return value.")]
        public void GlassWindow(IMargins margins)
        {
            var interopMargins = new Margin(margins);
            NativeMethods.DwmExtendFrameIntoClientArea(_windowHandle, ref interopMargins);
        }

        public IntPtr WindowHandle
        {
            get { return _windowHandle; }
        }
    }
}